package com.zx.idc.backend.gui.slog;


import com.baomidou.mybatisplus.plugins.Page;
import com.zx.idc.backend.gui.common.BasicBaseApi;
import com.zx.idc.backend.gui.common.Result;
import com.zx.idc.backend.gui.common.base.BaseExcelApi;
import com.zx.idc.backend.gui.slog.service.SlogHotDomainInterfaceService;
import com.zx.idc.common.exception.FTPUploadFailedException;
import com.zx.idc.ds.slog.entity.SlogHotDomain;
import com.zx.idc.ds.slog.service.ISlogHotDomainService;
import com.zx.idc.ds.slog.vo.SlogHotDomainVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 活跃域名 前端控制器
 * </p>
 *
 * @author rxliuli
 * @since 2019-01-31
 */


@RestController
@RequestMapping("/api/slogHotDomain")
public class SlogHotDomainController extends BasicBaseApi<ISlogHotDomainService, SlogHotDomain> implements BaseExcelApi<ISlogHotDomainService, SlogHotDomainVo> {

    @Autowired
    private SlogHotDomainInterfaceService slogHotDomainInterfaceService;


    @GetMapping("/query-page")
    @RequiresPermissions("regulatory-log:slog-hot-domain")
    public Result<Page<SlogHotDomainVo>> page(Page<SlogHotDomainVo> page, SlogHotDomainVo slogHotDomainVo) {
        return success(service.pageByParam(page, slogHotDomainVo));
    }

    @GetMapping("/list")
    @RequiresPermissions("regulatory-log:slog-hot-domain")
    public Result<List<SlogHotDomainVo>> list(SlogHotDomainVo slogHotDomainVo) {
        return success(service.listByParam(slogHotDomainVo));
    }

    @PostMapping(value = "/report-data")
    @RequiresPermissions("regulatory-log:slog-hot-domain:edit")
    public Result<Boolean> reportData(@RequestBody List<SlogHotDomainVo> slogHotDomainVos) {
        String msg;
        try {
            return success(slogHotDomainInterfaceService.reportData(slogHotDomainVos));
        } catch (FTPUploadFailedException e) {
            log.error(e.getMessage(), e);
            msg = e.getMessage();
        }
        return error(msg);
    }


}

